<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="工艺路线编号" prop="routeCode">
        <el-input
          v-model="queryParams.routeCode"
          placeholder="请输入工艺路线编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工艺路线名称" prop="routeName">
        <el-input
          v-model="queryParams.routeName"
          placeholder="请输入工艺路线名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否启用" prop="enableFlag">
        <el-input
          v-model="queryParams.enableFlag"
          placeholder="请输入是否启用"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:post:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:post:edit']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:post:remove']"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:post:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="postList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="工艺路线编号" align="center" prop="routeCode">
        <template slot-scope="scope">
          <el-button
            type="text"
            @click="selectInfo(scope.row)"
            v-hasPermi="['system:post:edit']"
          >{{ scope.row.routeCode }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="工艺路线名称" align="center" prop="routeName"/>
      <el-table-column label="工艺路线说明" align="center" prop="routeDesc"/>
      <el-table-column label="是否启用" align="center" prop="enableFlag">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_production_type" :value="scope.row.enableFlag"/>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="remark"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:post:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:post:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改岗位对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="110px" :disabled="isTabsVisible2">
        <!-- 用栅格布局将三个表单项放在一行 -->
        <el-row :gutter="20"> <!-- gutter 是列之间的间距 -->
          <!-- 工艺路线编号：占 8 格 -->
          <el-col :span="8">
            <el-form-item label="工艺路线编号" prop="routeCode">
              <el-input v-model="form.routeCode" placeholder="请输入工艺路线编号"/>
            </el-form-item>
          </el-col>
          <!-- 工艺路线名称：占 8 格 -->
          <el-col :span="8">
            <el-form-item label="工艺路线名称" prop="routeName">
              <el-input v-model="form.routeName" placeholder="请输入工艺路线名称"/>
            </el-form-item>
          </el-col>
          <!-- 是否启用：占 8 格（总和 8+8+8=24） -->
          <el-col :span="8">
            <el-form-item label="是否启用" prop="enableFlag">
              <el-radio-group v-model="form.enableFlag">
                <el-radio
                  v-for="dict in dict.type.sys_production_type"
                  :key="dict.value"
                  :label="dict.value"
                >{{ dict.label }}
                </el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>

        <!-- 剩余表单项保持不变 -->
        <el-form-item label="工艺路线说明" prop="routeDesc">
          <el-input v-model="form.routeDesc" type="textarea" placeholder="请输入工艺路线说明"/>
        </el-form-item>
        <el-form-item label="工艺路线备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
        </el-form-item>
      </el-form>

      <el-tabs type="border-card" v-if="isTabsVisible">
        <el-tab-pane label="组成工序">
          <el-row :gutter="10" class="mb8" v-if="isTabsVisible1">
            <el-col :span="1.5">
              <el-button
                type="primary"
                plain
                icon="el-icon-plus"
                size="mini"
                @click="handleAdd1"
                v-hasPermi="['system:post:add']"
              >新增
              </el-button>
            </el-col>
            <el-col :span="1.5">
              <el-button
                type="success"
                plain
                icon="el-icon-edit"
                size="mini"
                :disabled="single1"
                @click="handleUpdate"
                v-hasPermi="['system:post:edit']"
              >修改
              </el-button>
            </el-col>
            <el-col :span="1.5">
              <el-button
                type="danger"
                plain
                icon="el-icon-delete"
                size="mini"
                :disabled="multiple1"
                @click="handleDelete1"
                v-hasPermi="['system:post:remove']"
              >删除
              </el-button>
            </el-col>
<!--            <el-col :span="1.5">-->
<!--              <el-button-->
<!--                type="warning"-->
<!--                plain-->
<!--                icon="el-icon-download"-->
<!--                size="mini"-->
<!--                @click="handleExport"-->
<!--                v-hasPermi="['system:post:export']"-->
<!--              >导出-->
<!--              </el-button>-->
<!--            </el-col>-->
            <!--            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>-->
          </el-row>

          <el-table v-loading="loading" :data="postList1" @selection-change="handleSelectionChange1">
            <el-table-column type="selection" width="55" align="center"/>
            <el-table-column label="序号" align="center" prop="orderNum" width="100"/>
            <el-table-column label="工序编码" align="center" prop="processCode"/>
            <el-table-column label="工序名称" align="center" prop="processName"/>
            <el-table-column label="下一个工序名称" align="center" prop="nextProcessName"/>
            <el-table-column label="与下一道工序关系" align="center" prop="linkType"/>
            <el-table-column label="甘特图显示颜色" align="center" prop="colorCode"/>
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width" v-if="isTabsVisible1">
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="text"
                  icon="el-icon-edit"
                  @click="handleUpdate1(scope.row)"
                  v-hasPermi="['system:post:edit']"
                >修改
                </el-button>
                <el-button
                  size="mini"
                  type="text"
                  icon="el-icon-delete"
                  @click="handleDelete1(scope.row)"
                  v-hasPermi="['system:post:remove']"
                >删除
                </el-button>
              </template>
            </el-table-column>
          </el-table>

          <pagination
            v-show="total1>0"
            :total="total1"
            :page.sync="queryParams1.pageNum"
            :limit.sync="queryParams1.pageSize"
            @pagination="getList1"
          />
        </el-tab-pane>
        <el-tab-pane label="关联产品">
          <el-form :model="queryParams2" ref="queryForm2" size="small" :inline="true" v-show="showSearch"
                   label-width="100px" v-if="false">
            <el-form-item label="产品物料编码" prop="itemCode">
              <el-input
                v-model="queryParams2.itemCode"
                placeholder="请输入产品物料编码"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="产品物料名称" prop="itemName">
              <el-input
                v-model="queryParams2.itemName"
                placeholder="请输入产品物料名称"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>

            <el-form-item>
              <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
              <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-form>

          <el-row :gutter="10" class="mb8" v-if="isTabsVisible1">
            <el-col :span="1.5">
              <el-button
                type="primary"
                plain
                icon="el-icon-plus"
                size="mini"
                @click="handleAdd2"
                v-hasPermi="['system:post:add']"
              >新增
              </el-button>
            </el-col>
            <el-col :span="1.5">
              <el-button
                type="success"
                plain
                icon="el-icon-edit"
                size="mini"
                :disabled="single2"
                @click="handleUpdate2"
                v-hasPermi="['system:post:edit']"
              >修改
              </el-button>
            </el-col>
            <el-col :span="1.5">
              <el-button
                type="danger"
                plain
                icon="el-icon-delete"
                size="mini"
                :disabled="multiple2"
                @click="handleDelete2"
                v-hasPermi="['system:post:remove']"
              >删除
              </el-button>
            </el-col>
<!--            <el-col :span="1.5">-->
<!--              <el-button-->
<!--                type="warning"-->
<!--                plain-->
<!--                icon="el-icon-download"-->
<!--                size="mini"-->
<!--                @click="handleExport"-->
<!--                v-hasPermi="['system:post:export']"-->
<!--              >导出-->
<!--              </el-button>-->
<!--            </el-col>-->
            <!--            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>-->
          </el-row>

          <el-table v-loading="loading" :data="postList2" @selection-change="handleSelectionChange2">
            <el-table-column type="selection" width="55" align="center"/>
            <el-table-column label="产品物料编码" align="center" prop="itemCode">
              <template slot-scope="scope">
                <el-button
                  type="text"
                  @click="searchproductform(scope.row)"
                  v-hasPermi="['system:post:edit']"
                >{{ scope.row.itemCode }}
                </el-button>
              </template>
            </el-table-column>
            <el-table-column label="产品物料名称" align="center" prop="itemName"/>
            <el-table-column label="规格型号" align="center" prop="specification"/>
            <el-table-column label="单位" align="center" prop="unitOfMeasure"/>
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width" v-if="isTabsVisible1">
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="text"
                  icon="el-icon-edit"
                  @click="handleUpdate2(scope.row)"
                  v-hasPermi="['system:post:edit']"
                >修改
                </el-button>
                <el-button
                  size="mini"
                  type="text"
                  icon="el-icon-delete"
                  @click="handleDelete2(scope.row)"
                  v-hasPermi="['system:post:remove']"
                >删除
                </el-button>
              </template>
            </el-table-column>
          </el-table>

          <pagination
            v-show="total2>0"
            :total="total2"
            :page.sync="queryParams2.pageNum"
            :limit.sync="queryParams2.pageSize"
            @pagination="getList2"
          />
        </el-tab-pane>
      </el-tabs>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>


    <el-dialog :title="title1" :visible.sync="sync1" width="1000px">
      <el-form ref="processform" :model="processform" :rules="rules" label-width="150px" :disabled="isTabsVisible2">
        <!-- 用栅格布局将三个表单项放在一行 -->
        <el-row :gutter="20"> <!-- gutter 是列之间的间距 -->
          <!-- 工艺路线编号：占 8 格 -->
          <el-col :span="12">
            <el-form-item label="序号" prop="">
              <el-input-number v-model="processform.orderNum" :min="0" label="描述文字"></el-input-number>
            </el-form-item>
          </el-col>
          <!-- 工艺路线名称：占 8 格 -->
          <el-col :span="12">
            <el-form-item label="工序" prop="">
              <el-input v-model="processform.processName" placeholder="请选择工序"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20"> <!-- gutter 是列之间的间距 -->
          <!-- 工艺路线编号：占 8 格 -->
          <el-col :span="12">
            <el-form-item label="与下一道工序关系" prop="">
              <el-input v-model="processform.linkType" placeholder="请选择与下一道工序关系"/>
            </el-form-item>
          </el-col>
          <!-- 工艺路线名称：占 8 格 -->
          <el-col :span="12">
            <el-form-item label="甘特图显示颜色" prop="">
              <el-row>
                <el-col :span="8">
                  <el-color-picker v-model="processform.colorCode"></el-color-picker>
                </el-col>
                <el-col :span="16">
                  <el-input v-model="processform.colorCode" placeholder="请选择颜色"
                            style="width: 200px;margin-bottom: 10px"/>
                </el-col>
              </el-row>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20"> <!-- gutter 是列之间的间距 -->
          <el-col :span="12">
            <el-form-item label="准备时间" prop="">
              <el-input-number v-model="processform.defaultPreTime" :min="0" label="描述文字"></el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="等待时间" prop="">
              <el-input-number v-model="processform.defaultSufTime" :min="0" label="描述文字"></el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="工艺路线备注" prop="remark">
          <el-input v-model="processform.remark" type="textarea" placeholder="请输入内容"/>
        </el-form-item>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitprocessform">确 定</el-button>
        <el-button @click="cancelprocessform">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="title2" :visible.sync="sync2" width="1000px">
      <el-form ref="productform" :model="productform" :rules="rules" label-width="110px" :disabled="isTabsVisible2">
        <!-- 用栅格布局将三个表单项放在一行 -->
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="产品物料编码" prop="itemCode">
              <el-input placeholder="请选择产品" v-model="productform.itemCode" class="input-with-select"
                        :disabled="true">
                <el-button slot="append" icon="el-icon-search" @click="search"></el-button>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="产品物料名称" prop="itemName">
              <el-input v-model="productform.itemName" placeholder="请选择产品" :disabled="true"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="单位" prop="unitOfMeasure">
              <el-input v-model="productform.unitOfMeasure" placeholder="请选择产品" :disabled="true"/>
            </el-form-item>
          </el-col>
        </el-row>

        <!-- 剩余表单项保持不变 -->
        <el-form-item label="规格型号" prop="specification">
          <el-input v-model="productform.specification" type="textarea" placeholder="请选择产品" :disabled="true"/>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="productform.remark" type="textarea" placeholder="请输入内容"/>
        </el-form-item>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitproductform">确 定</el-button>
        <el-button @click="cancleproductform">取 消</el-button>
      </div>
    </el-dialog>
    <mydialog v-if="mydialog" @dialog-closed="closemydialog" @submit="getInfo"></mydialog>
  </div>
</template>

<script>
import {listProcess, getProcess, delProcess, addRouteProcess, addProcess, updateProcess} from "@/api/system/process"
import {
  getList2,
  getList1,
  delRouteProcess,
  getRouteProcess,
  updateRouteProcess,
  addRouteProduct, getRouteProduct, updateRouteProduct, delRouteProduct
} from "../../../api/system/process";
import mydialog from "../process/dialog.vue";

export default {
  components: {mydialog},
  name: "Process",
  dicts: ['sys_production_type'],
  data() {
    return {
      searchproductforms:true,
      mydialog: false,
      idparam: null,
      sync1: false,
      sync2: false,
      isTabsVisible: true,
      isTabsVisible1: true,
      isTabsVisible2: true,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      ids1: [],
      ids2: [],
      // 非单个禁用
      single: true,
      single1: true,
      single2: true,
      // 非多个禁用
      multiple: true,
      multiple1: true,
      multiple2: true,

      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 总条数
      total1: 0,
      // 总条数
      total2: 0,
      // 岗位表格数据
      postList: [],
      postList1: [],
      postList2: [],
      // 弹出层标题
      title: "",
      title1: "",
      title2: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        routeCode: undefined,
        routeName: undefined,
        enableFlag: undefined
      },
      queryParams1: {
        pageNum: 1,
        pageSize: 10,
      },
      queryParams2: {
        pageNum: 1,
        pageSize: 10,
        itemCode: undefined,
        itemName: undefined,
      },
      // 表单参数
      form: {},
      processform: {
        routeId: undefined,
        orderNum: 1,
        processName: undefined,
        linkType: undefined,
        colorCode: undefined,
        remark: undefined,
        defaultPreTime: 0,
        defaultSufTime: 0,
      },
      productform: {
        routeId: undefined,
        itemCode: undefined,
        itemName: undefined,
        unitOfMeasure: undefined,
        specification: undefined,
        remark: undefined,
      },
      // 表单校验
      rules: {
        routeCode: [
          {required: true, message: "工艺路线编号不能为空", trigger: "blur"}
        ],
        routeName: [
          {required: true, message: "工艺路线名称不能为空", trigger: "blur"}
        ],
        enableFlag: [
          {required: true, message: "是否启用不能为空", trigger: "blur"}
        ]
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getInfo(row) {
      this.productform.itemCode = row.itemCode
      this.productform.itemName = row.itemName
      this.productform.unitOfMeasure = row.unitOfMeasure
      this.productform.specification = row.specification
    },
    search() {
      this.mydialog = true
    },
    searchproductform(row){
      this.productform.itemCode = row.itemCode
      this.productform.itemName = row.itemName
      this.productform.unitOfMeasure = row.unitOfMeasure
      this.productform.specification = row.specification
      this.productform.remark = row.remark

      this.sync2= true
      this.searchproductforms=false
    },
    closemydialog() {
      this.mydialog = false
    },
    getList1(routeId) {
      getList1({routeId}).then(response => {
        console.log(response)
        this.postList1 = response.data
        this.total1 = response.data.length
        this.loading = false
      })
    },
    getList2(routeId) {
      getList2({routeId}).then(response => {
        console.log(response)
        this.postList2 = response.data
        this.total2 = response.data.length
        this.loading = false
      })
    },
    // 显示数据
    selectInfo(row) {
      this.reset()
      this.isTabsVisible = true
      this.isTabsVisible1 = false
      this.isTabsVisible2 = true
      const routeId = row.routeId || this.ids
      this.getList2(routeId)
      this.getList1(row.routeId)
      getProcess(routeId).then(response => {
        this.form = response.data
        this.open = true
        this.title = "查看工艺流程"
      })
    },
    /** 查询岗位列表 */
    getList() {
      this.loading = true
      listProcess(this.queryParams).then(response => {
        console.log(response)
        this.postList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    cancelprocessform() {
      this.sync1 = false
      // this.getList1()
    },
    cancleproductform(){
      this.sync2 = false
    },
    // 表单重置
    reset() {
      this.form = {
        routeId: undefined,
        routeCode: undefined,
        routeName: undefined,
        routeDesc: undefined,
        status: "0",
        remark: undefined
      }
      this.resetForm("form")
    },
    reset1() {
      this.processform = {
        routeId: undefined,
        orderNum: 1,
        processName: undefined,
        linkType: undefined,
        colorCode: undefined,
        remark: undefined,
        defaultPreTime: 0,
        defaultSufTime: 0,
      }
      this.resetForm("processform")
    },
    reset2() {
      this.productform = {
        routeId: undefined,
        itemCode: undefined,
        itemName: undefined,
        unitOfMeasure: undefined,
        specification: undefined,
        remark: undefined,
      }
      this.resetForm("productform")
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm")
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.routeId)
      this.single = selection.length != 1
      this.multiple = !selection.length
    },
    handleSelectionChange1(selection) {
      this.ids1 = selection.map(item => item.recordId)
      this.single1 = selection.length != 1
      this.multiple1 = !selection.length
    },
    handleSelectionChange2(selection) {
      this.ids2 = selection.map(item => item.recordId)
      this.single2 = selection.length != 1
      this.multiple2 = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.isTabsVisible = false
      this.isTabsVisible2 = false
      this.open = true
      this.title = "添加工艺流程"
    },
    handleAdd1() {
      this.reset1()
      this.sync1 = true
      this.processform.routeId = this.idparam
      this.title1 = "添加工艺组成"
    },
    handleAdd2() {
      this.reset2()
      this.sync2 = true
      this.productform.routeId = this.idparam
      this.title2 = "添加产品制程"
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      this.isTabsVisible = true
      this.isTabsVisible1 = true
      this.isTabsVisible2 = false
      const routeId = row.routeId || this.ids
      this.idparam = row.routeId
      this.getList2(row.routeId)
      this.getList1(row.routeId)
      getProcess(routeId).then(response => {
        this.form = response.data
        this.open = true
        this.title = "修改工艺流程"
      })
    },
    handleUpdate1(row) {
      this.reset1()
      const recordId = row.recordId || this.ids1
      getRouteProcess(recordId).then(response => {
        this.processform = response.data
        this.title1 = "修改工艺组成"
        this.sync1 = true
      })
    },
    handleUpdate2(row) {
      this.reset2()
      const recordId = row.recordId || this.ids2
      getRouteProduct(recordId).then(response => {
        this.productform = response.data
        this.title1 = "修改产品制程"
        this.sync2 = true
      })
    },
    /** 提交按钮 */
    submitForm: function () {
      if (this.isTabsVisible1 == false) {
        this.open = false
      } else {
        this.$refs["form"].validate(valid => {
          if (valid) {
            if (this.form.routeId != undefined) {
              updateProcess(this.form).then(response => {
                this.$modal.msgSuccess("修改成功")
                this.open = false
                this.getList()
              })
            } else {
              addProcess(this.form).then(response => {
                this.$modal.msgSuccess("新增成功")
                this.open = false
                this.getList()
              })
            }
          }
        })
      }
    },
    submitprocessform() {
      if (this.processform.recordId != undefined) {
        updateRouteProcess(this.processform).then(response => {
          this.$modal.msgSuccess("修改成功")
          this.sync1 = false
          this.getList1(this.idparam)
        })
      } else {
        addRouteProcess(this.processform).then(response => {
          this.$modal.msgSuccess("新增成功")
          this.getList1(this.idparam)
          this.sync1 = false
        })
      }
    },
    submitproductform() {
      if(this.searchproductforms){
        if (this.productform.recordId != undefined) {
          updateRouteProduct(this.productform).then(response => {
            this.$modal.msgSuccess("修改成功")
            this.sync2 = false
            this.getList2(this.idparam)
          })
        } else {
          addRouteProduct(this.productform).then(response => {
            this.$modal.msgSuccess("新增成功")
            this.getList2(this.idparam)
            this.sync2 = false
          })
        }
      }else {
        this.sync2 = false
        this.searchproductforms=true
      }
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const routeId = row.routeId || this.ids
      console.log(routeId)

      this.$modal.confirm('是否确认删除岗位编号为"' + routeId + '"的数据项？').then(function () {
        return delProcess(routeId)
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess("删除成功")
      }).catch(() => {
      })
    },
    handleDelete1(row) {
      const recordId = row.recordId || this.ids1
      this.$modal.confirm('是否确认删除编号为"' + recordId + '"的数据项？').then(function () {
        return delRouteProcess(recordId)
      }).then(() => {
        this.getList1(this.idparam)
        this.$modal.msgSuccess("删除成功")
      }).catch(() => {
      })
    },
    handleDelete2(row) {
      console.log(row)
      const recordId = row.recordId || this.ids2
      this.$modal.confirm('是否确认删除编号为"' + recordId + '"的数据项？').then(function () {
        return delRouteProduct(recordId)
      }).then(() => {
        this.getList2(this.idparam)
        this.$modal.msgSuccess("删除成功")
      }).catch(() => {
      })
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/process/export', {
        ...this.queryParams
      }, `process_${new Date().getTime()}.xlsx`)
    }
  }
}
</script>
